home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / Pdmod / modules / net / route.m < prev    next >
Encoding:
Text File  |  2002-10-28  |  12.1 KB  |  302 lines

  1. /* $Id: route.h,v 1.9 1993/06/04 11:16:15 jraja Exp $
  2.  *
  3.  * Copyright (c) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>,
  4.  *                    Helsinki University of Technology, Finland.
  5.  *                    All rights reserved.
  6.  *
  7.  * route.h --- Generic Routing Routines
  8.  *
  9.  * Last modified: Fri Jun  4 00:39:43 1993 jraja
  10.  *
  11.  * HISTORY
  12.  * $Log: route.h,v $
  13.  * Revision 1.9  1993/06/04  11:16:15  jraja
  14.  * Fixes for first public release.
  15.  *
  16.  * Revision 1.8  1993/05/29  20:44:42  jraja
  17.  * Removed obsolete definitions.
  18.  *
  19.  * Revision 1.7  1993/05/16  21:09:43  ppessi
  20.  * RCS version changed.
  21.  *
  22.  * Revision 1.6  1993/05/03  10:26:28  jraja
  23.  *  Put some KERNEL specific definitions inside #ifdef KERNEL ... #endif
  24.  *
  25.  * Revision 1.5  93/05/02  17:32:02  17:32:02  jraja (Jarno Tapio Rajahalme)
  26.  * Removed some obsolete definitions,
  27.  * included protos from distinct proto file here.
  28.  * 
  29.  * Revision 1.4  93/04/05  17:47:28  17:47:28  jraja (Jarno Tapio Rajahalme)
  30.  * Commneted out #include <gateway.h> since every c-file includes
  31.  * conf.h which contains the definition for GATEWAY.
  32.  * 
  33.  * Revision 1.3  93/03/05  03:12:54  03:12:54  ppessi (Pekka Pessi)
  34.  * Compiles with SASC. Initial test version
  35.  * 
  36.  * Revision 1.2  93/02/25  16:50:25  16:50:25  jraja (Jarno Tapio Rajahalme)
  37.  * added inclusion of route prototypes at the end of the file.
  38.  * 
  39.  * Revision 1.1  92/11/20  14:59:28  14:59:28  jraja (Jarno Tapio Rajahalme)
  40.  * Initial revision
  41.  * 
  42.  *
  43.  */
  44.  
  45. /* 
  46.  * Mach Operating System
  47.  * Copyright (c) 1992 Carnegie Mellon University
  48.  * All Rights Reserved.
  49.  * 
  50.  * Permission to use, copy, modify and distribute this software and its
  51.  * documentation is hereby granted, provided that both the copyright
  52.  * notice and this permission notice appear in all copies of the
  53.  * software, derivative works or modified versions, and any portions
  54.  * thereof, and that both notices appear in supporting documentation.
  55.  * 
  56.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  57.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  58.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  59.  * 
  60.  * Carnegie Mellon requests users of this software to return to
  61.  * 
  62.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  63.  *  School of Computer Science
  64.  *  Carnegie Mellon University
  65.  *  Pittsburgh PA 15213-3890
  66.  * 
  67.  * any improvements or extensions that they make and grant Carnegie Mellon 
  68.  * the rights to redistribute these changes.
  69.  */
  70. /*
  71.  * HISTORY
  72.  * Log: route.h,v
  73.  * Revision 2.1  92/04/21  17:13:52  rwd
  74.  * BSDSS
  75.  * 
  76.  *
  77.  */
  78.  
  79. /*
  80.  * Copyright (c) 1980, 1986 Regents of the University of California.
  81.  * All rights reserved.
  82.  *
  83.  * Redistribution and use in source and binary forms, with or without
  84.  * modification, are permitted provided that the following conditions
  85.  * are met:
  86.  * 1. Redistributions of source code must retain the above copyright
  87.  *    notice, this list of conditions and the following disclaimer.
  88.  * 2. Redistributions in binary form must reproduce the above copyright
  89.  *    notice, this list of conditions and the following disclaimer in the
  90.  *    documentation and/or other materials provided with the distribution.
  91.  * 3. All advertising materials mentioning features or use of this software
  92.  *    must display the following acknowledgement:
  93.  *      This product includes software developed by the University of
  94.  *      California, Berkeley and its contributors.
  95.  * 4. Neither the name of the University nor the names of its contributors
  96.  *    may be used to endorse or promote products derived from this software
  97.  *    without specific prior written permission.
  98.  *
  99.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  100.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  101.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  102.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  103.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  104.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  105.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  106.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  107.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  108.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  109.  * SUCH DAMAGE.
  110.  *
  111.  *      @(#)route.h     7.13 (Berkeley) 4/25/91
  112.  */
  113.  
  114. MODULE 'exec/tasks'
  115.  
  116. /*
  117.  * Kernel resident routing tables.
  118.  * 
  119.  * The routing tables are initialized when interface addresses
  120.  * are set by making entries for all directly connected interfaces.
  121.  */
  122.  
  123. /*
  124.  * A route consists of a destination address and a reference
  125.  * to a routing entry.  These are often held by protocols
  126.  * in their control blocks, e.g. inpcb.
  127.  */
  128. OBJECT route
  129.     ro_rt:PTR TO rtentry,
  130.     ro_dst:sockaddr
  131.  
  132.  
  133. /*
  134.  * These numbers are used by reliable protocols for determining
  135.  * retransmission behavior and are included in the routing structure.
  136.  */
  137. OBJECT rt_metrics
  138.     rmx_locks:ULONG,      /* Kernel must leave these values alone */
  139.     rmx_mtu:ULONG,        /* MTU for this path */
  140.     rmx_hopcount:ULONG,   /* max hops expected */
  141.     rmx_expire:ULONG,     /* lifetime for route, e.g. redirect */
  142.     rmx_recvpipe:ULONG,   /* inbound delay-bandwith product */
  143.     rmx_sendpipe:ULONG,   /* outbound delay-bandwith product */
  144.     rmx_ssthresh:ULONG,   /* outbound gateway buffer limit */
  145.     rmx_rtt:ULONG,        /* estimated round trip time */
  146.     rmx_rttvar:ULONG      /* estimated rtt variance */
  147.  
  148.  
  149. /*
  150.  * rmx_rtt and rmx_rttvar are stored as microseconds;
  151.  * RTTTOPRHZ(rtt) converts to a value suitable for use
  152.  * by a protocol slowtimo counter.
  153.  */
  154. #define RTM_RTTUNIT     1000000 /* units for rtt, rttvar, as units per sec */
  155. #define RTTTOPRHZ(r)    ((r) / (RTM_RTTUNIT / PR_SLOWHZ))
  156.  
  157. /*
  158.  * We distinguish between routes to hosts and routes to networks,
  159.  * preferring the former if available.  For each route we infer
  160.  * the interface to use from the gateway address supplied when
  161.  * the route was entered.  Routes that forward packets through
  162.  * gateways are marked so that the output routines know to address the
  163.  * gateway rather than the ultimate destination.
  164.  */
  165.  
  166. #define rt_key(r)       (((r).rt_nodes.rn_key))
  167. #define rt_mask(r)      (((r).rt_nodes.rn_mask))
  168.  
  169. OBJECT rtentry
  170.     rt_nodes[2]:radix_node, /* tree glue, and other values */
  171.     rt_gateway:PTR TO sockaddr,   /* value */
  172.     rt_flags:WORD,               /* up/down?, host/net */
  173.     rt_refcnt:WORD,              /* # held references */
  174.     rt_use:ULONG,                 /* raw # packets forwarded */
  175.     rt_ifp:PTR TO ifnet,          /* the answer: interface to use */
  176.     rt_ifa:PTR TO ifaddr,         /* the answer: interface to use */
  177.     rt_genmask:PTR TO sockaddr,   /* for generation of cloned routes */
  178.     rt_llinfo:PTR TO BYTE,              /* pointer to link level info cache */
  179.     rt_rmx:rt_metrics,      /* metrics used by rx'ing protocols */
  180.     rt_idle:WORD                /* easy to tell llayer still live */
  181.  
  182. /*
  183.  * Following structure necessary for 4.3 compatibility;
  184.  * We should eventually move it to a compat file.
  185.  */
  186. OBJECT  ortentry
  187.     rt_hash:ULONG,                /* to speed lookups */
  188.     rt_dst:sockaddr,        /* key */
  189.     rt_gateway:sockaddr,    /* value */
  190.     rt_flags:WORD,               /* up/down?, host/net */
  191.     rt_refcnt:WORD,              /* # held references */
  192.     rt_use:ULONG,                 /* raw # packets forwarded */
  193.     rt_ifp:PTR TO finet          /* the answer: interface to use */
  194.  
  195.  
  196. #define RTF_UP          $1             /* route useable */
  197. #define RTF_GATEWAY     $2             /* destination is a gateway */
  198. #define RTF_HOST        $4             /* host entry (net otherwise) */
  199. #define RTF_REJECT      $8             /* host or net unreachable */
  200. #define RTF_DYNAMIC     $10            /* created dynamically (by redirect) */
  201. #define RTF_MODIFIED    $20            /* modified dynamically (by redirect) */
  202. #define RTF_DONE        $40            /* message confirmed */
  203. #define RTF_MASK        $80            /* subnet mask present */
  204. #define RTF_CLONING     $100           /* generate new routes on use */
  205. #define RTF_XRESOLVE    $200           /* external daemon resolves name */
  206. #define RTF_LLINFO      $400           /* generated by ARP or ESIS */
  207. #define RTF_PROTO2      $4000          /* protocol specific routing flag */
  208. #define RTF_PROTO1      $8000          /* protocol specific routing flag */
  209.  
  210.  
  211. /*
  212.  * Routing statistics.
  213.  */
  214. OBJECT rtstat
  215.     rts_badredirect:WORD,        /* bogus redirect calls */
  216.     rts_dynamic:WORD,            /* routes created by redirects */
  217.     rts_newgateway:WORD,         /* routes modified by redirects */
  218.     rts_unreach_WORD,            /* lookups which failed */
  219.     rts_wildcard:WORD           /* lookups satisfied by a wildcard */
  220. /*
  221.  * Structures for routing messages.
  222.  */
  223. OBJECT rt_msghdr
  224.     rtm_msglen:UWORD,     /* to skip over non-understood messages */
  225.     rtm_version:UBYTE,    /* future binary compatability */
  226.     rtm_type:UBYTE,       /* message type */
  227.     rtm_index_UWORD,      /* index for associated ifp */
  228.     rtm_pid:PTR TO Task,        /* identify sender */
  229.     rtm_addrs:LONG,      /* bitmask identifying sockaddrs in msg */
  230.     rtm_seq:LONG,        /* for sender to identify action */
  231.     rtm_errno:LONG,      /* why failed */
  232.     rtm_flags:LONG,      /* flags, incl. kern & message, e.g. DONE */
  233.     rtm_use:LONG,        /* from rtentry */
  234.     rtm_inits:ULONG,      /* which metrics we are initializing */
  235.     rtm_rmx:rt_metrics /* metrics themselves */
  236.  
  237.  
  238. OBJECT route_cb
  239.     ip_count:LONG,
  240.     ns_count:LONG,
  241.     iso_count:LONG,
  242.     any_count:LONG
  243.  
  244. #define RTM_VERSION     2       /* Up the ante and ignore older versions */
  245.  
  246. #define RTM_ADD         $1     /* Add Route */
  247. #define RTM_DELETE      $2     /* Delete Route */
  248. #define RTM_CHANGE      $3     /* Change Metrics or flags */
  249. #define RTM_GET         $4     /* Report Metrics */
  250. #define RTM_LOSING      $5     /* Kernel Suspects Partitioning */
  251. #define RTM_REDIRECT    $6     /* Told to use different route */
  252. #define RTM_MISS        $7     /* Lookup failed on this address */
  253. #define RTM_LOCK        $8     /* fix specified metrics */
  254. #define RTM_OLDADD      $9     /* caused by SIOCADDRT */
  255. #define RTM_OLDDEL      $a     /* caused by SIOCDELRT */
  256. #define RTM_RESOLVE     $b     /* req to resolve dst to LL addr */
  257.  
  258. #define RTV_MTU         $1     /* init or lock _mtu */
  259. #define RTV_HOPCOUNT    $2     /* init or lock _hopcount */
  260. #define RTV_EXPIRE      $4     /* init or lock _hopcount */
  261. #define RTV_RPIPE       $8     /* init or lock _recvpipe */
  262. #define RTV_SPIPE       $10    /* init or lock _sendpipe */
  263. #define RTV_SSTHRESH    $20    /* init or lock _ssthresh */
  264. #define RTV_RTT         $40    /* init or lock _rtt */
  265. #define RTV_RTTVAR      $80    /* init or lock _rttvar */
  266.  
  267. #define RTA_DST         $1     /* destination sockaddr present */
  268. #define RTA_GATEWAY     $2     /* gateway sockaddr present */
  269. #define RTA_NETMASK     $4     /* netmask sockaddr present */
  270. #define RTA_GENMASK     $8     /* cloning mask sockaddr present */
  271. #define RTA_IFP         $10    /* interface name sockaddr present */
  272. #define RTA_IFA         $20    /* interface addr sockaddr present */
  273. #define RTA_AUTHOR      $40    /* sockaddr for author of redirect */
  274.  
  275. /*
  276. extern struct route_cb route_cb;
  277.  
  278. #define RTFREE(rt) \
  279.         if ((rt)->rt_refcnt <= 1) \
  280.                 rtfree(rt); \
  281.         else \
  282.                 (rt)->rt_refcnt--;
  283.  
  284. extern struct   rtstat  rtstat;
  285.  
  286. void rtinitheads(void);
  287. void rtalloc(struct route * ro);
  288. struct rtentry * rtalloc1(struct sockaddr * dst, int report);
  289. void rtfree(struct rtentry * rt);
  290. void rtredirect(struct sockaddr * dst, struct sockaddr * gateway,
  291.                struct sockaddr * netmask, int flags,
  292.                struct sockaddr * src, struct rtentry ** rtp);
  293. int rtioctl(int req, caddr_t data);
  294. struct ifaddr * ifa_ifwithroute(int flags, struct sockaddr * dst,
  295.                                 struct sockaddr * gateway);
  296. int rtrequest(int req, struct sockaddr * dst, struct sockaddr * gateway,
  297.               struct sockaddr * netmask, int flags, struct rtentry ** ret_nrt);
  298. void rt_maskedcopy(struct sockaddr * src, struct sockaddr * dst,
  299.                   struct sockaddr * netmask);
  300. int rtinit(struct ifaddr * ifa, int cmd, int flags);
  301. */
  302.